#ifndef __BOOTLOADER_H__
#define __BOOTLOADER_H__

#include "gd32f10x.h"

// #define FLASH_BASE          0x08000000	//FLASH基地址
#define PAGE_SIZE	        1024	    //页大小
#define PAGE_NUM	        128		    //页数

/* 分区         大小        扇区        说明
bootloader      20K        0-10      引导程序
app             234K       11-126    应用程序
flag            2K         127       版本信息
*/
#define BOOTLOADER_ADDR         0x08000000
#define BOOTLOADER_PAGE_START   0
#define BOOTLOADER_PAGE_NUM     10
#define BOOTLOADER_FLASH_SIZE   (PAGE_SIZE * BOOTLOADER_PAGE_NUM)
#define APPLICATION_ADDR        (BOOTLOADER_ADDR + PAGE_SIZE * BOOTLOADER_PAGE_NUM)
#define APPLICATION_PAGE_START  10
#define APPLICATION_PAGE_NUM    (PAGE_NUM - BOOTLOADER_PAGE_NUM - 1)
#define APPLICATION_FLASH_SIZE  (PAGE_SIZE * APPLICATION_PAGE_NUM)
#define FLAG_ADDR               (APPLICATION_ADDR + PAGE_SIZE * APPLICATION_PAGE_NUM)
#define FLAG_PAGE_START         127
#define FLAG_PAGE_NUM           1
#define FLAG_FLASH_SIZE         (PAGE_SIZE * FLAG_PAGE_NUM)
#endif /* __BOOTLOADER_H__ */
